﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormProject
{
    public partial class MahsupFisiFrm : Form
    {
        public MahsupFisiFrm()
        {
            InitializeComponent();
        }
        DBBaglantiDataContext db = new DBBaglantiDataContext();
        private void dataGridView1_CurrentCellChanged(object sender, EventArgs e)
        {

            try
            {
 foreach (DataGridViewTextBoxCell item in dataGridView1.SelectedCells)
            {
                if (item.ColumnIndex == 2)
                {
                    var sorgu = (from x in db.HesapPlanis where x.HesapNo ==dataGridView1.Rows[item.RowIndex].Cells[1].Value.ToString() select x.HesapAciklama).FirstOrDefault();
                    if (sorgu != null)
                    {
                        dataGridView1.Rows[item.RowIndex].Cells[2].Value = sorgu;
                        SendKeys.Send("\t"); //klavyeden tab bastırdık
                    }
                }
            }
            }
            catch (Exception)
            {
                MessageBox.Show("Hata");
            }

            //if (dataGridView1.SelectedCells[1] != null)
            //{
            //   
            //}
            //else
            //{
            //    MessageBox.Show("Test");
            //}
        }

        private void dataGridView1_KeyPress(object sender, KeyPressEventArgs e)
        {

        }

        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 1)
            {
                HesapPlanSeciciForm frm = new HesapPlanSeciciForm(e.RowIndex);
                frm.Show();
            }
        }
    }
}
